package me.snowiest.snowdrift.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import me.snowiest.snowdrift.entity.User;
import me.snowiest.snowdrift.mapper.PermissionMapper;
import me.snowiest.snowdrift.service.PermissionService;
import org.springframework.stereotype.Service;

import java.util.UUID;

@Service
public class PermissionServiceImpl extends ServiceImpl<PermissionMapper, User> implements PermissionService {

    @Override
    public String getToken(User user) {
        QueryWrapper<User> userQueryWrapper = new QueryWrapper<>();
        userQueryWrapper.eq("username", user.getUsername());
        User userByUsername = baseMapper.selectOne(userQueryWrapper);
        if (userByUsername.getPassword().equals(user.getPassword())) {
            return UUID.randomUUID().toString();
        }
        return "";
    }
}
